home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 120 / CD Gamer Issue 120 (March 2003) (Disc 2).ISO / mods / Q2_Codered / codeRED1_0.exe / Data1.cab / r_local.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-18  |  11.0 KB  |  427 lines

  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20.  
  21. #ifdef _WIN32
  22. #  include <windows.h>
  23. #endif
  24.  
  25. #include <stdio.h>
  26.  
  27. #include <GL/gl.h>
  28. #include <math.h>
  29.  
  30. #ifndef __linux__
  31. #ifndef GL_COLOR_INDEX8_EXT
  32. #define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX
  33. #endif
  34. #endif
  35.  
  36. #include "../client/ref.h"
  37. #include "../client/vid.h"
  38.  
  39. #include "qgl.h"
  40.  
  41. #define    REF_VERSION    "GL 0.01"
  42.  
  43. // up / down
  44. #define    PITCH    0
  45.  
  46. // left / right
  47. #define    YAW        1
  48.  
  49. // fall over
  50. #define    ROLL    2
  51.  
  52. extern    viddef_t    vid;
  53.  
  54.  
  55. /*
  56.  
  57.   skins will be outline flood filled and mip mapped
  58.   pics and sprites with alpha will be outline flood filled
  59.   pic won't be mip mapped
  60.  
  61.   model skin
  62.   sprite frame
  63.   wall texture
  64.   pic
  65.  
  66. */
  67.  
  68. typedef enum 
  69. {
  70.     it_skin,
  71.     it_sprite,
  72.     it_wall,
  73.     it_pic,
  74.     it_sky
  75. } imagetype_t;
  76.  
  77. typedef struct image_s
  78. {
  79.     char    name[MAX_QPATH];            // game path, including extension
  80.     imagetype_t    type;
  81.     int        width, height;                // source image
  82.     int        upload_width, upload_height;    // after power of two and picmip
  83.     int        registration_sequence;        // 0 = free
  84.     struct msurface_s    *texturechain;    // for sort-by-texture world drawing
  85.     int        texnum;                        // gl texture binding
  86.     float    sl, tl, sh, th;                // 0,0 - 1,1 unless part of the scrap
  87.     qboolean    scrap;
  88.     qboolean    has_alpha;
  89.     qboolean paletted;
  90. } image_t;
  91.  
  92. #define    TEXNUM_LIGHTMAPS    1024
  93. #define    TEXNUM_SCRAPS        1152
  94. #define    TEXNUM_IMAGES        1153
  95.  
  96. #define        MAX_GLTEXTURES    1024
  97.  
  98. //===================================================================
  99.  
  100. typedef enum
  101. {
  102.     rserr_ok,
  103.  
  104.     rserr_invalid_fullscreen,
  105.     rserr_invalid_mode,
  106.  
  107.     rserr_unknown
  108. } rserr_t;
  109.  
  110. #include "r_model.h"
  111.  
  112. void GL_BeginRendering (int *x, int *y, int *width, int *height);
  113. void GL_EndRendering (void);
  114.  
  115. void GL_SetDefaultState( void );
  116. void GL_UpdateSwapInterval( void );
  117.  
  118. extern    float    gldepthmin, gldepthmax;
  119.  
  120. #define    MAX_LBM_HEIGHT        512
  121.  
  122. #define BACKFACE_EPSILON    0.01
  123.  
  124.  
  125. //====================================================
  126.  
  127. extern    image_t        gltextures[MAX_GLTEXTURES];
  128. extern    int            numgltextures;
  129.  
  130.  
  131. extern    image_t        *r_notexture;
  132. extern    image_t        *r_particletexture;//gonna do it right here sucka - this will be where
  133. //we set the different types of particles.
  134. extern image_t        *r_smoketexture; //etc etc etc
  135. extern image_t        *r_explosiontexture;
  136. extern image_t        *r_bloodtexture;
  137. extern image_t        *r_pufftexture;
  138. extern image_t        *r_blastertexture;
  139. extern image_t        *r_bflashtexture;
  140. extern image_t        *r_leaderfieldtexture;
  141. extern  image_t     *r_shelltexture;     // c14 added shell texture
  142.  
  143. extern    entity_t    *currententity;
  144. extern    model_t        *currentmodel;
  145. extern    int            r_visframecount;
  146. extern    int            r_framecount;
  147. extern    cplane_t    frustum[4];
  148. extern    int            c_brush_polys, c_alias_polys;
  149.  
  150.  
  151. extern    int            gl_filter_min, gl_filter_max;
  152.  
  153. //
  154. // view origin
  155. //
  156. extern    vec3_t    vup;
  157. extern    vec3_t    vpn;
  158. extern    vec3_t    vright;
  159. extern    vec3_t    r_origin;
  160.  
  161. //
  162. // screen size info
  163. //
  164. extern    refdef_t    r_newrefdef;
  165. extern    int        r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
  166.  
  167. extern    cvar_t    *r_norefresh;
  168. extern    cvar_t    *r_lefthand;
  169. extern    cvar_t    *r_drawentities;
  170. extern    cvar_t    *r_drawworld;
  171. extern    cvar_t    *r_speeds;
  172. extern    cvar_t    *r_fullbright;
  173. extern    cvar_t    *r_novis;
  174. extern    cvar_t    *r_nocull;
  175. extern    cvar_t    *r_lerpmodels;
  176.  
  177. extern    cvar_t    *r_lightlevel;    // FIXME: This is a HACK to get the client's light level
  178.  
  179. extern cvar_t    *gl_vertex_arrays;
  180.  
  181. extern cvar_t    *gl_ext_swapinterval;
  182. extern cvar_t    *gl_ext_palettedtexture;
  183. extern cvar_t    *gl_ext_multitexture;
  184. extern cvar_t    *gl_ext_pointparameters;
  185. extern cvar_t    *gl_ext_compiled_vertex_array;
  186.  
  187. extern cvar_t    *gl_particle_min_size;
  188. extern cvar_t    *gl_particle_max_size;
  189. extern cvar_t    *gl_particle_size;
  190. extern cvar_t    *gl_particle_att_a;
  191. extern cvar_t    *gl_particle_att_b;
  192. extern cvar_t    *gl_particle_att_c;
  193.  
  194. extern    cvar_t    *gl_nosubimage;
  195. extern    cvar_t    *gl_bitdepth;
  196. extern    cvar_t    *gl_mode;
  197. extern    cvar_t    *gl_log;
  198. extern    cvar_t    *gl_lightmap;
  199. extern    cvar_t    *gl_shadows;
  200. extern    cvar_t    *gl_dynamic;
  201. extern  cvar_t  *gl_monolightmap;
  202. extern    cvar_t    *gl_nobind;
  203. extern    cvar_t    *gl_round_down;
  204. extern    cvar_t    *gl_picmip;
  205. extern    cvar_t    *gl_skymip;
  206. extern    cvar_t    *gl_showtris;
  207. extern    cvar_t    *gl_finish;
  208. extern    cvar_t    *gl_clear;
  209. extern    cvar_t    *gl_cull;
  210. extern    cvar_t    *gl_poly;
  211. extern    cvar_t    *gl_texsort;
  212. extern    cvar_t    *gl_polyblend;
  213. extern    cvar_t    *gl_flashblend;
  214. extern    cvar_t    *gl_lightmaptype;
  215. extern    cvar_t    *gl_modulate;
  216. extern    cvar_t    *gl_playermip;
  217. extern    cvar_t    *gl_drawbuffer;
  218. extern    cvar_t    *gl_3dlabs_broken;
  219. extern  cvar_t  *gl_driver;
  220. extern    cvar_t    *gl_swapinterval;
  221. extern    cvar_t    *gl_texturemode;
  222. extern    cvar_t    *gl_texturealphamode;
  223. extern    cvar_t    *gl_texturesolidmode;
  224. extern  cvar_t  *gl_saturatelighting;
  225. extern  cvar_t  *gl_lockpvs;
  226.  
  227. extern    cvar_t    *vid_fullscreen;
  228. extern    cvar_t    *vid_gamma;
  229.  
  230. extern    cvar_t    *intensity;
  231.  
  232. extern    int        gl_lightmap_format;
  233. extern    int        gl_solid_format;
  234. extern    int        gl_alpha_format;
  235. extern    int        gl_tex_solid_format;
  236. extern    int        gl_tex_alpha_format;
  237.  
  238. extern    int        c_visible_lightmaps;
  239. extern    int        c_visible_textures;
  240.  
  241. extern    float    r_world_matrix[16];
  242.  
  243. void GL_Bind (int texnum);
  244. void GL_MBind( GLenum target, int texnum );
  245. void GL_TexEnv( GLenum value );
  246. void GL_EnableMultitexture( qboolean enable );
  247. void GL_SelectTexture( GLenum );
  248.  
  249. void R_LightPoint (vec3_t p, vec3_t color);
  250. void R_PushDlights (void);
  251. void R_PushStains (void);
  252. void R_PushStainsForBModel (entity_t *e);
  253. void R_PushDlightsForBModel (entity_t *e);
  254.  
  255. //====================================================================
  256. typedef struct
  257. {
  258.     vec3_t    origin;
  259.     float    alpha;
  260.     float    dist;
  261.     int        type;
  262.     int        color;
  263. } gparticle_t;
  264.  
  265. extern    model_t    *r_worldmodel;
  266.  
  267. extern    unsigned    d_8to24table[256];
  268.  
  269. extern    int        registration_sequence;
  270.  
  271.  
  272. void V_AddBlend (float r, float g, float b, float a, float *v_blend);
  273.  
  274. int     R_Init( void *hinstance, void *hWnd );
  275. void    R_Shutdown( void );
  276.  
  277. void R_RenderView (refdef_t *fd);
  278. void GL_ScreenShot_f (void);
  279. void R_DrawAliasModel (entity_t *e);
  280. void R_DrawBrushModel (entity_t *e);
  281. void R_DrawSpriteModel (entity_t *e);
  282. void R_DrawBeam( entity_t *e );
  283. void R_DrawWorld (void);
  284. void R_RenderDlights (void);
  285. void R_DrawAlphaSurfaces (void);
  286. void R_RenderBrushPoly (msurface_t *fa);
  287. void R_InitParticleTexture (void);
  288. void Draw_InitLocal (void);
  289. void GL_SubdivideSurface (msurface_t *fa);
  290. qboolean R_CullBox (vec3_t mins, vec3_t maxs);
  291. void R_RotateForEntity (entity_t *e);
  292. void R_MarkLeaves (void);
  293.  
  294. void EmitWaterPolys (msurface_t *fa);
  295. void R_DrawSkyBox (void);
  296. void R_DrawSkyBoxVooDoo (void);
  297. void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
  298.  
  299. void    Draw_GetPicSize (int *w, int *h, char *name);
  300. void    Draw_Pic (int x, int y, char *name);
  301. void    Draw_StretchPic (int x, int y, int w, int h, char *name);
  302. void    Draw_Char (int x, int y, int c);
  303. void    Draw_TileClear (int x, int y, int w, int h, char *name);
  304. void    Draw_Fill (int x, int y, int w, int h, int c);
  305. void    Draw_FadeScreen (void);
  306. void    Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data);
  307.  
  308. void    R_BeginFrame( float camera_separation );
  309. void    R_SwapBuffers( int );
  310. void    R_SetPalette ( const unsigned char *palette);
  311.  
  312. int        Draw_GetPalette (void);
  313.  
  314. void    GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out,  int outwidth, int outheight);
  315.  
  316. image_t *R_RegisterSkin (char *name);
  317. image_t *R_RegisterParticlePic(char *name);
  318.  
  319. void    LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height);
  320. image_t *GL_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type, int bits);
  321. image_t    *GL_FindImage (char *name, imagetype_t type);
  322. void    GL_TextureMode( char *string );
  323. void    GL_ImageList_f (void);
  324.  
  325. void    GL_SetTexturePalette( unsigned palette[256] );
  326.  
  327. void    GL_InitImages (void);
  328. void    GL_ShutdownImages (void);
  329.  
  330. void    GL_FreeUnusedImages (void);
  331.  
  332. void    GL_TextureAlphaMode( char *string );
  333. void    GL_TextureSolidMode( char *string );
  334.  
  335. /*
  336. ** GL config stuff
  337. */
  338. #define GL_RENDERER_VOODOO        0x00000001
  339. #define GL_RENDERER_VOODOO2       0x00000002
  340. #define GL_RENDERER_VOODOO_RUSH    0x00000004
  341. #define GL_RENDERER_BANSHEE        0x00000008
  342. #define    GL_RENDERER_3DFX        0x0000000F
  343.  
  344. #define GL_RENDERER_PCX1        0x00000010
  345. #define GL_RENDERER_PCX2        0x00000020
  346. #define GL_RENDERER_PMX            0x00000040
  347. #define    GL_RENDERER_POWERVR        0x00000070
  348.  
  349. #define GL_RENDERER_PERMEDIA2    0x00000100
  350. #define GL_RENDERER_GLINT_MX    0x00000200
  351. #define GL_RENDERER_GLINT_TX    0x00000400
  352. #define GL_RENDERER_3DLABS_MISC    0x00000800
  353. #define    GL_RENDERER_3DLABS        0x00000F00
  354.  
  355. #define GL_RENDERER_REALIZM        0x00001000
  356. #define GL_RENDERER_REALIZM2    0x00002000
  357. #define    GL_RENDERER_INTERGRAPH    0x00003000
  358.  
  359. #define GL_RENDERER_3DPRO        0x00004000
  360. #define GL_RENDERER_REAL3D        0x00008000
  361. #define GL_RENDERER_RIVA128        0x00010000
  362. #define GL_RENDERER_DYPIC        0x00020000
  363.  
  364. #define GL_RENDERER_V1000        0x00040000
  365. #define GL_RENDERER_V2100        0x00080000
  366. #define GL_RENDERER_V2200        0x00100000
  367. #define    GL_RENDERER_RENDITION    0x001C0000
  368.  
  369. #define GL_RENDERER_O2          0x00100000
  370. #define GL_RENDERER_IMPACT      0x00200000
  371. #define GL_RENDERER_RE            0x00400000
  372. #define GL_RENDERER_IR            0x00800000
  373. #define    GL_RENDERER_SGI            0x00F00000
  374.  
  375. #define GL_RENDERER_MCD            0x01000000
  376. #define GL_RENDERER_OTHER        0x80000000
  377.  
  378. typedef struct
  379. {
  380.     int         renderer;
  381.     const char *renderer_string;
  382.     const char *vendor_string;
  383.     const char *version_string;
  384.     const char *extensions_string;
  385.  
  386.     qboolean    allow_cds;
  387. } glconfig_t;
  388.  
  389. typedef struct
  390. {
  391.     float        inverse_intensity;
  392.     qboolean    fullscreen;
  393.  
  394.     int            prev_mode;
  395.  
  396.     unsigned char *d_16to8table;
  397.  
  398.     int            lightmap_textures;
  399.  
  400.     int            currenttextures[2];
  401.     int            currenttmu;
  402.  
  403.     float        camera_separation;
  404.     qboolean    stereo_enabled;
  405. } glstate_t;
  406.  
  407. extern glconfig_t  gl_config;
  408. extern glstate_t   gl_state;
  409.  
  410. /*
  411. ====================================================================
  412.  
  413. IMPLEMENTATION SPECIFIC FUNCTIONS
  414.  
  415. ====================================================================
  416. */
  417.  
  418. void        GLimp_BeginFrame( float camera_separation );
  419. void        GLimp_EndFrame( void );
  420. int         GLimp_Init( void *hinstance, void *hWnd );
  421. void        GLimp_Shutdown( void );
  422. int         GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen );
  423. void        GLimp_AppActivate( qboolean active );
  424. void        GLimp_EnableLogging( qboolean enable );
  425. void        GLimp_LogNewFrame( void );
  426.  
  427.